//
//  FooterButton.m
//  musicPlayer
//
//  Created by 遇水 on 15/6/19.
//  Copyright (c) 2015年 YS. All rights reserved.
//

#import "FooterButton.h"
//修改image的位置
@implementation FooterButton


/**
 *  由于是通过storyboard创建的，所以不会调用initWithFrame方法，会调用下列方法
 *
 *  @param aDecoder <#aDecoder description#>
 *
 *  @return <#return value description#>
 */
-(id)initWithCoder:(NSCoder *)aDecoder{
    self = [super initWithCoder:aDecoder];
    if (self) {
        self.imageView.contentMode = UIViewContentModeCenter;
//        self.titleLabel.contentMode = UIViewContentModeCenter;
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        self.titleLabel.font = [UIFont systemFontOfSize:12];
        [self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    }
    return self;
}


-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        //设置内部图标居中
        self.imageView.contentMode = UIViewContentModeCenter;
//        self.imageView.contentMode = UIViewContentModeScaleToFill;
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        [self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//        self.titleLabel.font = ;
        //高亮时不需要内部调整图片为灰色
//        self.adjustsImageWhenHighlighted = NO;
    }
    return self;
}





/**
 *  设置内部图片的frame
 *
 *  @param contentRect <#contentRect description#>
 *
 *  @return <#return value description#>
 */
-(CGRect)imageRectForContentRect:(CGRect)contentRect{
    CGFloat imageX = 0;
    CGFloat imageY = 0;
    CGFloat imageW = self.width;
    CGFloat imageH = 30;
    return CGRectMake(imageX, imageY, imageW, imageH);
}
-(CGRect)titleRectForContentRect:(CGRect)contentRect{
    CGFloat titleX = 0;
    CGFloat titleY = 30;
    CGFloat titleW = self.width;
    CGFloat titleH = self.height - titleY;
    return CGRectMake(titleX, titleY, titleW, titleH);
}

@end
